{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Distance, Duration and Direction calculations\n",
    "Notebook that creates metrics for the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas as gpd\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import datetime\n",
    "import sys\n",
    "sys.path.append('../../../Scripts/') # link to scripts\n",
    "import preprocessing.translate\n",
    "import utils.spatial_utils\n",
    "import utils.temporal_utils\n",
    "import preprocessing.create_metrics\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# GLOBALS\n",
    "CAN_LAM = {'init':'epsg:3347'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# path to the MTL Trajet data \n",
    "path_2016 = \"../../../Data/mtl_trajet/mtl_trajet_2016.shp\"\n",
    "path_2017 = \"../../../Data/mtl_trajet/trajets_mtl_trajet_2017.shp\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "initialising crs\n",
      "translating data\n",
      "translating data\n"
     ]
    }
   ],
   "source": [
    "# translate and reproject data (see reprojection_timezone_and_translation notebook for details)\n",
    "gdf_2016 = preprocessing.translate.translate_data(path_2016)\n",
    "gdf_2017 = preprocessing.translate.translate_data(path_2017)\n",
    "\n",
    "# initalise the CRS\n",
    "if gdf_2016.crs == {}:\n",
    "    print(\"initialising crs\")\n",
    "    gdf_2016.crs = {'init': 'epsg:4326'}\n",
    "    \n",
    "if gdf_2017.crs == {}:\n",
    "    print(\"initialising crs\")\n",
    "    gdf_2017.crs = {'init': 'epsg:4326'}\n",
    "    \n",
    "# reproject data\n",
    "if not gdf_2016.crs == {'init': 'epsg:3347'}:\n",
    "    gdf_2016 = utils.spatial_utils.change_projection(gdf_2016)\n",
    "    \n",
    "if not gdf_2017.crs == {'init': 'epsg:3347'}:\n",
    "    gdf_2017 = utils.spatial_utils.change_projection(gdf_2017)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### distance & duration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "distance already calculated\n",
      "distance already calculated\n"
     ]
    }
   ],
   "source": [
    "if gdf_2016.crs != CAN_LAM:\n",
    "    gdf_2016 = utils.spatial_utils.change_projection(gdf_2016)\n",
    "\n",
    "if 'distance_m' not in gdf_2016.columns:\n",
    "    print(\"calculating distance\")\n",
    "    gdf_2016['distance_m'] = gdf_2016['geometry'].apply(lambda row: row.length)\n",
    "else:\n",
    "    print('distance already calculated')\n",
    "    \n",
    "if gdf_2017.crs != CAN_LAM:\n",
    "    gdf_2017 = utils.spatial_utils.change_projection(gdf_2017)\n",
    "\n",
    "if 'distance_m' not in gdf_2017.columns:\n",
    "    print(\"calculating distance\")\n",
    "    gdf_2017['distance_m'] = gdf_2017['geometry'].apply(lambda row: row.length)\n",
    "else:\n",
    "    print('distance already calculated')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "duration already calculated\n"
     ]
    }
   ],
   "source": [
    "if 'duration' not in gdf_2016.columns:\n",
    "    gdf_2016['duration'] = pd.to_datetime(gdf_2016['endtime']) - pd.to_datetime(gdf_2016['starttime'])\n",
    "    gdf_2016['duration'] = gdf_2016['duration'].apply(lambda tm: tm.seconds)\n",
    "else:\n",
    "    print('duration already calculated')\n",
    "    \n",
    "if 'duration' not in gdf_2017.columns:\n",
    "    gdf_2017['duration'] = pd.to_datetime(gdf_2017['endtime']) - pd.to_datetime(gdf_2017['starttime'])\n",
    "    gdf_2017['duration'] = gdf_2017['duration'].apply(lambda tm: tm.seconds)\n",
    "else:\n",
    "    print('duration already calculated')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_trip</th>\n",
       "      <th>avg_speed</th>\n",
       "      <th>duration</th>\n",
       "      <th>mode</th>\n",
       "      <th>purpose</th>\n",
       "      <th>n_coord</th>\n",
       "      <th>segments</th>\n",
       "      <th>starttime</th>\n",
       "      <th>endtime</th>\n",
       "      <th>geometry</th>\n",
       "      <th>distance_m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1724206</td>\n",
       "      <td>4.4</td>\n",
       "      <td>460</td>\n",
       "      <td>walking</td>\n",
       "      <td>returning_home</td>\n",
       "      <td>12</td>\n",
       "      <td>[{\"id\": 1150192, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-07T20:37:26-04</td>\n",
       "      <td>2016-09-07T20:45:06-04</td>\n",
       "      <td>LINESTRING (7628287.236741193 1247680.17623496...</td>\n",
       "      <td>415.236330</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1724208</td>\n",
       "      <td>10.7</td>\n",
       "      <td>2146</td>\n",
       "      <td>combination</td>\n",
       "      <td>work</td>\n",
       "      <td>120</td>\n",
       "      <td>[{\"id\": 1140016, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T07:43:23-04</td>\n",
       "      <td>2016-09-08T08:19:09-04</td>\n",
       "      <td>LINESTRING (7627830.06960756 1247172.275532002...</td>\n",
       "      <td>6407.207910</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1889461</td>\n",
       "      <td>15.4</td>\n",
       "      <td>447</td>\n",
       "      <td>public_transport</td>\n",
       "      <td>leisure</td>\n",
       "      <td>36</td>\n",
       "      <td>[{\"id\": 1390715, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T19:46:14-04</td>\n",
       "      <td>2016-09-08T19:53:41-04</td>\n",
       "      <td>LINESTRING (7632055.840015979 1247584.15415876...</td>\n",
       "      <td>1843.264582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1724219</td>\n",
       "      <td>16.8</td>\n",
       "      <td>591</td>\n",
       "      <td>car</td>\n",
       "      <td>returning_home</td>\n",
       "      <td>45</td>\n",
       "      <td>[{\"id\": 1210250, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T21:41:37-04</td>\n",
       "      <td>2016-09-08T21:51:28-04</td>\n",
       "      <td>LINESTRING (7630236.131991102 1247926.25343475...</td>\n",
       "      <td>2657.421830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2071985</td>\n",
       "      <td>6.9</td>\n",
       "      <td>279</td>\n",
       "      <td>combination</td>\n",
       "      <td>pick_up_drop_off</td>\n",
       "      <td>12</td>\n",
       "      <td>[{\"id\": 1140287, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-09T16:49:12-04</td>\n",
       "      <td>2016-09-09T16:53:51-04</td>\n",
       "      <td>LINESTRING (7628479.883114187 1247193.3864914,...</td>\n",
       "      <td>481.960461</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_trip  avg_speed  duration              mode           purpose  n_coord  \\\n",
       "0  1724206        4.4       460           walking    returning_home       12   \n",
       "1  1724208       10.7      2146       combination              work      120   \n",
       "2  1889461       15.4       447  public_transport           leisure       36   \n",
       "3  1724219       16.8       591               car    returning_home       45   \n",
       "4  2071985        6.9       279       combination  pick_up_drop_off       12   \n",
       "\n",
       "                                            segments               starttime  \\\n",
       "0  [{\"id\": 1150192, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-07T20:37:26-04   \n",
       "1  [{\"id\": 1140016, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T07:43:23-04   \n",
       "2  [{\"id\": 1390715, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T19:46:14-04   \n",
       "3  [{\"id\": 1210250, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T21:41:37-04   \n",
       "4  [{\"id\": 1140287, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-09T16:49:12-04   \n",
       "\n",
       "                  endtime                                           geometry  \\\n",
       "0  2016-09-07T20:45:06-04  LINESTRING (7628287.236741193 1247680.17623496...   \n",
       "1  2016-09-08T08:19:09-04  LINESTRING (7627830.06960756 1247172.275532002...   \n",
       "2  2016-09-08T19:53:41-04  LINESTRING (7632055.840015979 1247584.15415876...   \n",
       "3  2016-09-08T21:51:28-04  LINESTRING (7630236.131991102 1247926.25343475...   \n",
       "4  2016-09-09T16:53:51-04  LINESTRING (7628479.883114187 1247193.3864914,...   \n",
       "\n",
       "    distance_m  \n",
       "0   415.236330  \n",
       "1  6407.207910  \n",
       "2  1843.264582  \n",
       "3  2657.421830  \n",
       "4   481.960461  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_trip</th>\n",
       "      <th>mode</th>\n",
       "      <th>purpose</th>\n",
       "      <th>starttime</th>\n",
       "      <th>endtime</th>\n",
       "      <th>geometry</th>\n",
       "      <th>distance_m</th>\n",
       "      <th>duration</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1547</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>2017-09-18 04:16:58UTC</td>\n",
       "      <td>2017-09-18 04:26:26UTC</td>\n",
       "      <td>LINESTRING (7624015.797731054 1247372.35912242...</td>\n",
       "      <td>1530.222174</td>\n",
       "      <td>568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>308312</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>2017-09-18 06:17:46UTC</td>\n",
       "      <td>2017-09-18 06:58:49UTC</td>\n",
       "      <td>LINESTRING (7624029.565886395 1247375.82561127...</td>\n",
       "      <td>324.869460</td>\n",
       "      <td>2463</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>384772</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>2017-09-18 09:30:24UTC</td>\n",
       "      <td>2017-09-18 10:17:28UTC</td>\n",
       "      <td>(LINESTRING (7607307.107749194 1253237.7069476...</td>\n",
       "      <td>32009.701647</td>\n",
       "      <td>2824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>150744</td>\n",
       "      <td>car</td>\n",
       "      <td>pick_up_drop_off</td>\n",
       "      <td>2017-09-18 10:02:50UTC</td>\n",
       "      <td>2017-09-18 10:17:12UTC</td>\n",
       "      <td>LINESTRING (7624322.265039734 1247672.97005955...</td>\n",
       "      <td>9935.922336</td>\n",
       "      <td>862</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>199011</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>2017-09-18 10:18:40UTC</td>\n",
       "      <td>2017-09-18 10:27:44UTC</td>\n",
       "      <td>(LINESTRING (7616402.393582943 1246769.1996916...</td>\n",
       "      <td>563.806088</td>\n",
       "      <td>544</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_trip  mode           purpose               starttime  \\\n",
       "0     1547  None              None  2017-09-18 04:16:58UTC   \n",
       "1   308312  None              None  2017-09-18 06:17:46UTC   \n",
       "2   384772  None              None  2017-09-18 09:30:24UTC   \n",
       "3   150744   car  pick_up_drop_off  2017-09-18 10:02:50UTC   \n",
       "4   199011  None              None  2017-09-18 10:18:40UTC   \n",
       "\n",
       "                  endtime                                           geometry  \\\n",
       "0  2017-09-18 04:26:26UTC  LINESTRING (7624015.797731054 1247372.35912242...   \n",
       "1  2017-09-18 06:58:49UTC  LINESTRING (7624029.565886395 1247375.82561127...   \n",
       "2  2017-09-18 10:17:28UTC  (LINESTRING (7607307.107749194 1253237.7069476...   \n",
       "3  2017-09-18 10:17:12UTC  LINESTRING (7624322.265039734 1247672.97005955...   \n",
       "4  2017-09-18 10:27:44UTC  (LINESTRING (7616402.393582943 1246769.1996916...   \n",
       "\n",
       "     distance_m  duration  \n",
       "0   1530.222174       568  \n",
       "1    324.869460      2463  \n",
       "2  32009.701647      2824  \n",
       "3   9935.922336       862  \n",
       "4    563.806088       544  "
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2017.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Direction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "calculating mean direction (may take 5-10 minutes)\n",
      "calculating mean direction (may take 5-10 minutes)\n"
     ]
    }
   ],
   "source": [
    "#TODO: add more detail\n",
    "gdf_2016 = preprocessing.create_metrics.calc_direction(gdf_2016)\n",
    "gdf_2017 = preprocessing.create_metrics.calc_direction(gdf_2017)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_trip</th>\n",
       "      <th>avg_speed</th>\n",
       "      <th>duration</th>\n",
       "      <th>mode</th>\n",
       "      <th>purpose</th>\n",
       "      <th>n_coord</th>\n",
       "      <th>segments</th>\n",
       "      <th>starttime</th>\n",
       "      <th>endtime</th>\n",
       "      <th>geometry</th>\n",
       "      <th>distance_m</th>\n",
       "      <th>direction</th>\n",
       "      <th>magnitude</th>\n",
       "      <th>carddir</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1724206</td>\n",
       "      <td>4.4</td>\n",
       "      <td>460</td>\n",
       "      <td>walking</td>\n",
       "      <td>returning_home</td>\n",
       "      <td>12</td>\n",
       "      <td>[{\"id\": 1150192, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-07T20:37:26-04</td>\n",
       "      <td>2016-09-07T20:45:06-04</td>\n",
       "      <td>LINESTRING (-73.5983784907 45.53640603229992, ...</td>\n",
       "      <td>415.236330</td>\n",
       "      <td>317.610420</td>\n",
       "      <td>0.227492</td>\n",
       "      <td>NW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1724208</td>\n",
       "      <td>10.7</td>\n",
       "      <td>2146</td>\n",
       "      <td>combination</td>\n",
       "      <td>work</td>\n",
       "      <td>120</td>\n",
       "      <td>[{\"id\": 1140016, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T07:43:23-04</td>\n",
       "      <td>2016-09-08T08:19:09-04</td>\n",
       "      <td>LINESTRING (-73.6057240345 45.53323548669993, ...</td>\n",
       "      <td>6407.207910</td>\n",
       "      <td>155.205916</td>\n",
       "      <td>0.246612</td>\n",
       "      <td>SSE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1889461</td>\n",
       "      <td>15.4</td>\n",
       "      <td>447</td>\n",
       "      <td>public_transport</td>\n",
       "      <td>leisure</td>\n",
       "      <td>36</td>\n",
       "      <td>[{\"id\": 1390715, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T19:46:14-04</td>\n",
       "      <td>2016-09-08T19:53:41-04</td>\n",
       "      <td>LINESTRING (-73.55313767040001 45.526113951199...</td>\n",
       "      <td>1843.264582</td>\n",
       "      <td>305.597389</td>\n",
       "      <td>0.470022</td>\n",
       "      <td>NW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1724219</td>\n",
       "      <td>16.8</td>\n",
       "      <td>591</td>\n",
       "      <td>car</td>\n",
       "      <td>returning_home</td>\n",
       "      <td>45</td>\n",
       "      <td>[{\"id\": 1210250, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T21:41:37-04</td>\n",
       "      <td>2016-09-08T21:51:28-04</td>\n",
       "      <td>LINESTRING (-73.5739219686 45.53360049689993, ...</td>\n",
       "      <td>2657.421830</td>\n",
       "      <td>290.430625</td>\n",
       "      <td>0.303495</td>\n",
       "      <td>WNW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2071985</td>\n",
       "      <td>6.9</td>\n",
       "      <td>279</td>\n",
       "      <td>combination</td>\n",
       "      <td>pick_up_drop_off</td>\n",
       "      <td>12</td>\n",
       "      <td>[{\"id\": 1140287, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-09T16:49:12-04</td>\n",
       "      <td>2016-09-09T16:53:51-04</td>\n",
       "      <td>LINESTRING (-73.5977874175 45.53178334249993, ...</td>\n",
       "      <td>481.960461</td>\n",
       "      <td>9.350188</td>\n",
       "      <td>0.220694</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_trip  avg_speed  duration              mode           purpose  n_coord  \\\n",
       "0  1724206        4.4       460           walking    returning_home       12   \n",
       "1  1724208       10.7      2146       combination              work      120   \n",
       "2  1889461       15.4       447  public_transport           leisure       36   \n",
       "3  1724219       16.8       591               car    returning_home       45   \n",
       "4  2071985        6.9       279       combination  pick_up_drop_off       12   \n",
       "\n",
       "                                            segments               starttime  \\\n",
       "0  [{\"id\": 1150192, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-07T20:37:26-04   \n",
       "1  [{\"id\": 1140016, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T07:43:23-04   \n",
       "2  [{\"id\": 1390715, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T19:46:14-04   \n",
       "3  [{\"id\": 1210250, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T21:41:37-04   \n",
       "4  [{\"id\": 1140287, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-09T16:49:12-04   \n",
       "\n",
       "                  endtime                                           geometry  \\\n",
       "0  2016-09-07T20:45:06-04  LINESTRING (-73.5983784907 45.53640603229992, ...   \n",
       "1  2016-09-08T08:19:09-04  LINESTRING (-73.6057240345 45.53323548669993, ...   \n",
       "2  2016-09-08T19:53:41-04  LINESTRING (-73.55313767040001 45.526113951199...   \n",
       "3  2016-09-08T21:51:28-04  LINESTRING (-73.5739219686 45.53360049689993, ...   \n",
       "4  2016-09-09T16:53:51-04  LINESTRING (-73.5977874175 45.53178334249993, ...   \n",
       "\n",
       "    distance_m   direction  magnitude carddir  \n",
       "0   415.236330  317.610420   0.227492      NW  \n",
       "1  6407.207910  155.205916   0.246612     SSE  \n",
       "2  1843.264582  305.597389   0.470022      NW  \n",
       "3  2657.421830  290.430625   0.303495     WNW  \n",
       "4   481.960461    9.350188   0.220694       N  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
